// 统一請求路径前缀在libs/axios.js中修改
import {
    commonUrl,
    deleteRequest,
    getRequest,
    getRequestWithNoToken,
    postRequest,
    postRequestWithNoForm,
    postRequestWithNoToken,
    postRequestWithNoTokenData,
    putRequest,
    putRequestWithNoForm,
} from "@/libs/axios";

// 文件上傳接口
export const uploadFile = commonUrl + "/common/common/upload/file";

//获取所有city
export const getAllCity = (params) => {
    return getRequest(commonUrl + '/common/common/region/allCity', params)
}

// 获取全部权限數据
export const getCurrentPermissionList = (params) => {
    return getRequest("/menu/memberMenu", params);
};
// 登陆
export const getHomeNotice = params => {
    return getRequest("/other/article/getByPage?type=STORE_ARTICLE&pageSize=15");
};

// 登陆
export const getSellerHomeData = params => {
    return getRequest("/statistics/index", params);
};


// 登陆
export const login = params => {
    return postRequestWithNoTokenData("/passport/login/userLogin", params);
};

// 手機登陆
export const storeSmsLogin = params => {
    return postRequestWithNoToken("/passport/login/smsLogin", params);
};

// 登出
export const logout = () => {
    return postRequest("/passport/login/logout");
};

// 获取用戶登錄信息
export const userInfo = params => {
    return getRequest("/user/info", params);
};
// 获取登錄信息
export const userMsg = params => {
    return getRequest('/settings/storeSettings', params)
}
//驗證短信驗證碼
export const validateCode = params => {
    return postRequestWithNoToken("/passport/login/resetByMobile", params);
};
// 初始化驗證碼
export const initCaptcha = params => {
    return getRequestWithNoToken("/common/captcha/init", params);
};
// 發送登錄短信驗證碼
export const sendLoginSms = (mobile, params) => {
    return getRequest(`/common/captcha/sendLoginSms/${mobile}`, params);
};
// 發送註冊短信驗證碼
export const sendRegistSms = (mobile, params) => {
    return getRequest(`/common/captcha/sendRegistSms/${mobile}`, params);
};
// 發送重置密碼短信驗證碼
export const sendResetSms = (mobile, params) => {
    return getRequest(`${commonUrl}/common/captcha/sendResetSms/${mobile}`, params);
};
// 發送修改绑定手機短信驗證碼
export const sendEditMobileSms = (mobile, params) => {
    return getRequest(`/common/captcha/sendEditMobileSms/${mobile}`, params);
};
// 通过手機重置密碼
export const resetByMobile = params => {
    return postRequest("/user/resetByMobile", params);
};
// 發送重置密碼邮件驗證碼
export const sendResetEmail = (email, params) => {
    return getRequest(`/email/sendResetCode/${email}`, params);
};
// 發送修改绑定邮件驗證碼
export const sendEditEmail = (email, params) => {
    return getRequest(`/email/sendEditCode/${email}`, params);
};
// 通过邮件重置密碼
export const resetByEmail = params => {
    return postRequest("/email/resetByEmail", params);
};
// 短信驗證碼登錄
export const smsLogin = params => {
    return postRequest("/user/smsLogin", params);
};
// IP天气信息
export const ipInfo = params => {
    return getRequest("/common/ip/info", params);
};
// 个人中心编辑
export const userInfoEdit = params => {
    return postRequest("/user/edit", params);
};
// 个人中心發送修改邮箱驗證邮件
export const sendCodeEmail = (email, params) => {
    return getRequest(`/email/sendCode/${email}`, params);
};
// 个人中心發送修改邮箱驗證邮件
export const editEmail = params => {
    return postRequest("/email/editEmail", params);
};
// 忘記密碼并修改
export const forgetAndModify = params => {
    return postRequest("/passport/login/resetPassword", params);
};
// 个人中心修改密碼
export const changePass = params => {
    return postRequest("/passport/login/modifyPass", params);
};
// 个人中心修改手機
export const changeMobile = params => {
    return postRequest("/user/changeMobile", params);
};
// 获取绑定賬號信息
export const relatedInfo = (username, params) => {
    return getRequest(`/relate/getRelatedInfo/${username}`, params);
};
// 解绑賬號
export const unRelate = params => {
    return postRequest("/relate/delByIds", params);
};
// 分頁获取绑定賬號信息
export const getRelatedListData = params => {
    return getRequest("/relate/findByCondition", params);
};
// 获取用戶數据 多條件
export const getUserListData = params => {
    return getRequest("/clerk", params);
};
// 通过用戶名搜索
export const searchUserByName = (username, params) => {
    return getRequest("/user/searchByName/" + username, params);
};
// 获取全部用戶數据
export const getAllUserData = params => {
    return getRequest("/user/getAll", params);
};

// 添加用戶
export const addUser = params => {
    return postRequest("/clerk", params);
};
// 编辑用戶
export const editUser = params => {
    return postRequest("/user/admin/edit", params);
};
// 启用用戶
export const enableUser = (id, params) => {
    return postRequest(`/user/admin/enable/${id}`, params);
};
// 禁用用戶
export const disableUser = (id, params) => {
    return postRequest(`/user/admin/disable/${id}`, params);
};
// 删除用戶
export const deleteUser = (ids, params) => {
    return deleteRequest(`/user/delByIds/${ids}`, params);
};
// 重置用戶密碼
export const resetUserPass = params => {
    return postRequest("/user/resetPass", params);
};
/****************************** 权限结束 */

// 分頁获取日誌數据
export const getLogListData = params => {
    return getRequest("/log/getAllByPage", params);
};
// 分頁获取消息數据
export const getMessageData = params => {
    return getRequest("/message/storeMessage/getByCondition", params);
};
// 获取單个消息詳情
export const getMessageDataById = (id, params) => {
    return getRequest(`/message/storeMessage/get/${id}`, params);
};
// 添加消息
export const addMessage = params => {
    return postRequest("/message/storeMessage/add", params);
};
// 编辑消息
export const editMessage = params => {
    return postRequest("/message/storeMessage/edit", params);
};
// 回收站還原消息
export const reductionMessage = (ids, params) => {
    return putRequest(`/message/storeMessage/${ids}/reduction`, params);
};
// 彻底删除消息
export const clearMessage = (ids, params) => {
    return deleteRequest(`/message/storeMessage/${ids}`, params);
};
// 已讀消息放入回收站
export const deleteMessage = (ids, params) => {
    return deleteRequest(`/message/storeMessage/${ids}/delete`, params);
};
// 分頁获取消息推送數据
export const getMessageSendData = params => {
    return getRequest("/message/storeMessage", params);
};
// 进入消息中心首次加载全部數据
export const getAllMessage = params => {
    return getRequest("/message/storeMessage/all", params);
};
// 已讀消息
export const read = (id) => {
    return putRequest(`/message/storeMessage/${id}/read`);
};
// 删除發送消息
export const deleteMessageSend = (ids, params) => {
    return deleteRequest(`/message/storeMessageSend/delByIds/${ids}`, params);
};

// 分頁获取文件數据
export const getFileListData = params => {
    return getRequest(`${commonUrl}/common/common/file`, params);
};

// 重命名文件
export const setFileLink = params => {
    return postRequest(`${commonUrl}/common/common/file/setLink`, params);
};
// 复制文件
export const copyFile = params => {
    return postRequest(`${commonUrl}/common/common/file/copy`, params);
};
// 重命名文件
export const renameFile = params => {
    return postRequest(`${commonUrl}/common/common/file/rename`, params);
};
// 删除文件
export const deleteFile = (ids, params) => {
    return deleteRequest(`${commonUrl}/common/common/file/delete/${ids}`, params);
};
// 下载文件
export const aliDownloadFile = (fKey, params) => {
    return getRequest(`${commonUrl}/common/common/file/ali/download/${fKey}`, params);
};

// 获取文件目录列表
export const getFileDirectory = () => {
    return getRequest(commonUrl + `/common/resource/fileDirectory`);
};

// 添加文件目录
export const addFileDirectory = (params) => {
    return postRequestWithNoForm(commonUrl + `/common/resource/fileDirectory`, params);
};


// 修改文件目录
export const updateFileDirectory = (params) => {
    return putRequestWithNoForm(commonUrl + `/common/resource/fileDirectory`, params);
};


// 删除文件目录
export const delFileDirectory = (id) => {
    return deleteRequest(commonUrl + `/common/resource/fileDirectory/${id}`);
};


// base64上傳
export const base64Upload = params => {
    return postRequest("/common/common/upload/file", params);
};


// 添加商品计量單位
export const addGoodsUnit = (params) => {
    return postRequest(`/goods/goodsUnit`, params);
};
// 分頁获取商品计量單位
export const getGoodsUnitPage = (params) => {
    return getRequest(`/goods/goodsUnit`, params);
};
// 编辑商品计量單位
export const updateGoodsUnit = (id, params) => {
    return putRequest(`/goods/goodsUnit/${id}`, params);
};
// 删除商品计量單位
export const delGoodsUnit = (ids) => {
    return deleteRequest(`/goods/goodsUnit/delete/${ids}`);
};

//
export const handleRefreshToken = (token) => {
    return getRequestWithNoToken(`/passport/login/refresh/${token}`);
};

// 获取一级部門
export const initDepartment = (params) => {
    return getRequest("/department", params);
};
// 添加部門
export const addDepartment = (params) => {
    return postRequest("/department", params);
};
// 删除部門
export const deleteDepartment = (ids, params) => {
    return deleteRequest(`/department/${ids}`, params);
};
// 编辑部門
export const editDepartment = (ids, params) => {
    return putRequest(`/department/${ids} `, params);
};
// 加载部門子级數据
export const loadDepartment = (id) => {
    return getRequest(`/department/${id}`);
};
// 搜索部門
export const searchDepartment = (params) => {
    return getRequest("/department", params);
};

// 通过部門获取全部角色數据
export const getUserByDepartmentId = (id, params) => {
    return getRequest(`/departmentRole/${id}`, params);
};

// 分頁获取角色數据
export const getRoleList = (params) => {
    return getRequest("/role", params);
};

// 通过部門修改绑定角色
export const updateDepartmentRole = (id, params) => {
    return putRequestWithNoForm(`/departmentRole/${id}`, params);
};

// 获取全部权限數据
export const getAllPermissionList = (params) => {
    return getRequest("/menu/tree", params);
};

// 添加角色
export const addRole = (params) => {
    return postRequest("/role", params);
};
// 删除角色
export const deleteRole = (ids, params) => {
    return deleteRequest(`/role/${ids}`, params);
};
// 编辑角色
export const editRole = (params) => {
    return putRequest(`/role/${params.roleId}`, params);
};

// 分配角色权限
export const editRolePerm = (params) => {
    return postRequest("/role/editRolePerm", params);
};
// 查看某角色拥有的菜單
export const selectRoleMenu = (params) => {
    return getRequest(`/roleMenu/${params}`);
};
// 保存角色菜單
export const saveRoleMenu = (id, params) => {
    return postRequestWithNoForm(`/roleMenu/${id}`, params);
};
// 获取全部角色數据
export const getAllRoleList = (params) => {
    return getRequest("/role", params);
};
export const checkClerk = (mobile) => {
    return postRequest(`/clerk/${mobile}/check`);
};

// 重置用戶密碼
export const resetPassword = (params) => {
    return postRequest(`/clerk/resetPassword/${params}`);
};
// 删除用戶
export const deleteClerk = (ids) => {
    return deleteRequest(`/clerk/delByIds/${ids}`);
};

// 禁 启用用戶
export const enableClerk = (id, params) => {
    return putRequest(`/clerk/enable/${id}`, params);
};
// 获取店员詳細
export const getClerk = (id) => {
    return getRequest(`/clerk/${id}`);
};

export const editOtherUser = (id, params) => {
    return putRequest(`/clerk/${id}`, params);
};

// /**
//  *  搜索部門 先加入此api防止运行warn
//  */
// export const searchDepartment = (params) => {
//   return getRequest("/permission/department/search", params);
// };
